﻿<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
    xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>
        Send E-Mail
      </Title>
    </Header>
    <Snippet>
      <Code Language="CSharp">
        <![CDATA[
		private void ThisApplication_Startup(object sender, System.EventArgs e)
		{
			SendEmailtoContacts();
		}

		private void SendEmailtoContacts()
		{
			string subjectEmail = "Meeting has been rescheduled.";
			string bodyEmail = "Meeting is one hour later.";
			Outlook.MAPIFolder sentContacts = (Outlook.MAPIFolder)
				this.ActiveExplorer().Session.GetDefaultFolder
				(Outlook.OlDefaultFolders.olFolderContacts);
			foreach (Outlook.ContactItem contact in sentContacts.Items)
			{
				if (contact.Email1Address.Contains("example.com"))
				{
					this.CreateEmailItem(subjectEmail, contact
						.Email1Address, bodyEmail);
				}
			}
		}

		private void CreateEmailItem(string subjectEmail,
			   string toEmail, string bodyEmail)
		{
			Outlook.MailItem eMail = (Outlook.MailItem)
				this.CreateItem(Outlook.OlItemType.olMailItem);
			eMail.Subject = subjectEmail;
			eMail.To = toEmail;
			eMail.Body = bodyEmail;
			eMail.Importance = Outlook.OlImportance.olImportanceLow;
			((Outlook._MailItem)eMail).Send();
		}

		]]>
	</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>